package com.gjs.common.exception;


import com.gjs.common.manager.response.RspEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * 自定义业务异常
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
public class BizException extends RuntimeException {

    /**
     * 响应枚举
     */
    private RspEnum err;

    /**
     * 错误信息
     */
    private String msg;

    public BizException(String msg) {
        this(RspEnum.FAIL, msg);
    }

    public BizException(RspEnum err) {
        this(err, err.getResultMsg());
    }

    public BizException(RspEnum err, String msg) {
        super(msg);
        this.err = err;
        this.msg = msg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}